package com.fang.dubbo.provider.config;

import com.fang.dubbo.provider.api.impl.TestApiImpl;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.stereotype.Component;

/**
 * @author fanglingxiao
 * @version 1.0
 * @description TODO
 * @date 2022/5/15 5:40 下午
 **/
@Component
public class MyTestApiPostProcessor implements BeanPostProcessor {

    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        if (bean instanceof TestApiImpl) {
            System.out.println("---------------");
            System.out.println("MyBeanPostProcessor before invoke,beanName=" + beanName);
            System.out.println("---------------");
        }
        return bean;
    }

    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        if (bean instanceof TestApiImpl) {
            System.out.println("---------------");
            System.out.println("MyBeanPostProcessor after invoke,beanName=" + beanName);
            System.out.println("---------------");
        }
        return bean;
    }
}
